package com.s69;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class MyWebMvcConfig extends WebMvcConfigurationSupport {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        //将目录c:/resources/下的资源在访问时映射到/**路径下
        registry.addResourceHandler("/**")
                .addResourceLocations(
                        "classpath:/META-INF/resources/",
                        "classpath:/resources/",
                        "classpath:/static/",
                        "classpath:/public/",
                        "file:D:/upimgs/");
    }
    @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/add").setViewName("add");
        registry.addViewController("/register").setViewName("register");
    }
}
